package com.braveman.im.http;


import android.text.TextUtils;

import com.braveman.im.constant.Constants;
import com.braveman.im.constant.HttpConfig;
import com.ht.baselibs.retrofit.interceptor.PreHeaderInterceptor;
import com.ht.baselibs.utils.DateUtils;
import com.ht.baselibs.utils.DeviceUtils;
import com.ht.baselibs.utils.SharedPreferencesUtils;

import java.util.HashMap;
import java.util.Map;

public class HeadInterceptor extends PreHeaderInterceptor {

    @Override
    protected Map<String, String> getHeaders() {
        Map<String, String> map = new HashMap<>();
        map.put(HttpConfig.GlobalParam.APP_TYPE, "android");
        map.put(HttpConfig.GlobalParam.V, "v1.0");
        map.put(HttpConfig.GlobalParam.TIME_STAMP, DateUtils.getCurrentTime());
        map.put(HttpConfig.GlobalParam.DEVICE_ID, DeviceUtils.getDeviceId() + "");
        String token = SharedPreferencesUtils.getString(Constants.TOKEN, "");
        if (!TextUtils.isEmpty(token)) {
            map.put(HttpConfig.GlobalParam.ACCESS_TOKEN, token);
        }
        return map;
    }
}